package example

import (
	"jslog/system/config"

	"github.com/patrickmn/go-cache"
	"github.com/qiniu/qmgo"
	"github.com/redis/go-redis/v9"
	"github.com/songzhibin97/gkit/cache/local_cache"
	"github.com/spf13/viper"
	"go.uber.org/zap"
	"gorm.io/gorm"
)

var (
	JSLOG_DB      *gorm.DB
	JSLOG_REDIS   redis.UniversalClient
	JSLOG_MONGO   *qmgo.QmgoClient
	JSLOG_CONF    config.Server
	JSLOG_CACHE   *cache.Cache
	JSLOG_VP      *viper.Viper
	JSLOG_LOG     *zap.Logger
	JSLOG_DB_TYPE config.System
	BlackCache    local_cache.Cache
)

func Initialize() {
	JSLOG_VP = Viper(&JSLOG_CONF)
	JSLOG_DB = Gorm(JSLOG_CONF)
	if JSLOG_CONF.System.UseMultipoint || JSLOG_CONF.System.UseRedis {
		JSLOG_REDIS = Redis(&JSLOG_CONF.Redis, JSLOG_LOG)
	}
	if JSLOG_CONF.System.UseCache {
		JSLOG_CACHE = Cache(&JSLOG_CONF.Cache)
	}
}
